package view;

import java.util.ArrayList;
import java.util.List;

import model.Contract;
import model.User;
import Repository.MarketingRepository;
import Repository.Repository;
import Repository.RepositoryFactory;
import constants.SMSConstants;

public class ManagerView extends View{
		
	public ManagerView(User user){
		super(user);
	}
	
	@SuppressWarnings("unchecked")
	public void retrieveView(){
		Repository repository = RepositoryFactory.getRepository(SMSConstants.LEAD);
		leadObjects.clear();
		leadObjects.addAll(MarketingRepository.getRawLeads());
		leadObjects.addAll(repository.retrieve("Imported"));
		leadObjects.addAll(repository.retrieve("Prepared"));
		
		oppObjects.clear();
		repository = RepositoryFactory.getRepository(SMSConstants.OPPORTUNITY);
		oppObjects.addAll(repository.retrieve("Quoted"));
		
		
		 contractObjects.clear();
		repository = RepositoryFactory.getRepository(SMSConstants.CONTRACT);
		
		List lstContracts = repository.retrieve("Prepared");
		
		for(Object o : lstContracts){
			Contract c = (Contract)o;
			if(c.getNextApprover() == user.getId())
				contractObjects.add(c);
		}
		
		//contractObjects.addAll(repository.retrieve("Prepared"));
		contractObjects.addAll(repository.retrieve("Approved"));
				
	}

}
